package matrix;

public class Determinant {

	
	public static void main(String[] args) {
		int arr[][] = new int[4][4];
		if(isSquareMatrix(arr)){
			getDeterminant(arr);
		}else{
			throw new IllegalStateException("Given Array is not Square Matrix");
		}
	}
	
	
	
	private static int getArraySize(int[][] array){
		int finallength = 0;
		for(int i=0;i<array.length;i++){
			finallength += array[i].length;
		}
		return finallength;
	}
	
	
	private static int getDeterminant(int[][] array) {
		if(getArraySize(array)/array.length == 2){
		    return((array[0][0]*array[1][1])-(array[0][1]*array[1][0]));
		}else{
			throw new IllegalStateException("Given Array is not 2*2");
		}
	}
	
	private static void prepareMatrix(int[][] array){
		int[][] matrix = new int[(getArraySize(array)/array.length)-1][(getArraySize(array)/array.length)-1];
		
	}
	
	private static boolean isSquareMatrix(int[][] array){
		boolean result = false;
		int length = getArraySize(array);
		if(length/array.length == array.length){
			result = true;
		}
		return result;
	}

}
